package indi.gtl.superbrain.activitys;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import indi.gtl.superbrain.R;
import indi.gtl.superbrain.models.Constant;
import indi.gtl.superbrain.models.UserInfo;
import indi.gtl.superbrain.widget.CircleChart;

import java.util.Timer;
import java.util.TimerTask;


public class WaitClientActivity extends Activity implements Constant {

    UserInfo mUserInfo;
    UserInfo enemyInfo;

    RelativeLayout myuserInfoServiceRelativeLayout, enemyInfoServiceRelativeLayout;
    ImageView myuserHeadServiceImageView, enemyHeadServiceImageView;
    TextView myuserNameServiceTextView, myuserScoreServiceTextView,
            enemyNameServiceTextView, enemyScoreServiceTextView,
            waitServiceTextView;
    CircleChart infoChartServiceCircleChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service);
        if(getActionBar() != null)
        	getActionBar().hide();

        myuserInfoServiceRelativeLayout = (RelativeLayout) findViewById(R.id.myuserInfoServiceRelativeLayout);
        enemyInfoServiceRelativeLayout = (RelativeLayout) findViewById(R.id.enemyInfoServiceRelativeLayout);
        myuserHeadServiceImageView = (ImageView) findViewById(R.id.myuserHeadServiceImageView);
        enemyHeadServiceImageView = (ImageView) findViewById(R.id.enemyHeadServiceImageView);
        myuserNameServiceTextView = (TextView) findViewById(R.id.myuserNameServiceTextView);
        myuserScoreServiceTextView = (TextView) findViewById(R.id.myuserScoreServiceTextView);
        enemyNameServiceTextView = (TextView) findViewById(R.id.enemyNameServiceTextView);
        enemyScoreServiceTextView = (TextView) findViewById(R.id.enemyScoreServiceTextView);
        waitServiceTextView = (TextView) findViewById(R.id.waitServiceTextView);
        infoChartServiceCircleChart = (CircleChart) findViewById(R.id.infoChartServiceCircleChart);

        Intent data = getIntent();
        mUserInfo = (UserInfo) data.getSerializableExtra(KEY_MYUSER_INFO);
        enemyInfo = (UserInfo) data.getSerializableExtra(KEY_ENEMY_INFO);

        infoChartServiceCircleChart.setTitle(UserInfo.getTitles());

        myuserHeadServiceImageView.setImageResource(headList[mUserInfo.head % headList.length]);
        myuserNameServiceTextView.setText(mUserInfo.name);
        myuserScoreServiceTextView.setText(mUserInfo.sum_score + "");

        infoChartServiceCircleChart.addInfoList(mUserInfo.getInfoList());
        waitServiceTextView.setVisibility(View.GONE);
        myuserInfoServiceRelativeLayout.setVisibility(View.VISIBLE);

        enemyHeadServiceImageView.setImageResource(headList[enemyInfo.head % headList.length]);
        enemyNameServiceTextView.setText(enemyInfo.name);
        enemyScoreServiceTextView.setText(enemyInfo.sum_score + "");
        infoChartServiceCircleChart.addInfoList(enemyInfo.getInfoList());
        waitServiceTextView.setVisibility(View.GONE);
        enemyInfoServiceRelativeLayout.setVisibility(View.VISIBLE);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
